using System;
using System.Collections.Generic;
using System.Text;
using Csla.Data;

namespace MinaspetroLibrary.ConvenioPack
{
    [Serializable()]
    public class ConvenioSetorChildInfo : Csla.ReadOnlyBase<ConvenioSetorChildInfo>
    {
        #region Business Properties and Methods

        //declare members

        private Guid _id = Guid.NewGuid();

        private string _setor = string.Empty;

        [System.ComponentModel.DataObjectField(true, true)]
        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        public string Setor
        {
            get
            {
                return _setor;
            }
        }


        protected override object GetIdValue()
        {
            return _id.ToString();
        }

        #endregion //Business Properties and Methods

        #region Authorization Rules
        protected override void AddAuthorizationRules()
        {
            //TODO: Define authorization rules in ConvenioSetorChildInfo

        }

        #endregion //Authorization Rules

        #region Factory Methods
        internal static ConvenioSetorChildInfo GetConvenioSetorChildInfo(SafeDataReader dr)
        {
            return new ConvenioSetorChildInfo(dr);
        }

        private ConvenioSetorChildInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }
        #endregion //Factory Methods

        #region Data Access

        #region Data Access - Fetch
        private void Fetch(SafeDataReader dr)
        {
            FetchObject(dr);

            //load child object(s)
            FetchChildren(dr);

        }

        private void FetchObject(SafeDataReader dr)
        {
            _id = new Guid(dr["Id"].ToString());
            _setor = dr.GetString("Setor");

        }

        private void FetchChildren(SafeDataReader dr)
        {
        }
        #endregion //Data Access - Fetch
        #endregion //Data Access
    }
}
